from appium import webdriver
from time import sleep
import logging
import logging.config
import sys

sys.path.append(r'..')
from common.get_yaml_data import get_yaml_data

logging.config.fileConfig(r'..\config\log_conf.ini')
logger=logging.getLogger()

def desired_caps():
    data=get_yaml_data(r'..\config\dedirde_caps.yaml')
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '7'
    desired_caps['deviceName'] = '127.0.0.1:62001'
    desired_caps['app']=r'D:\tool\apk\kaoyanbang.apk'
    desired_caps['appPackage']=r'com.tal.kaoyan'
    desired_caps['appActivity']=r'com.tal.kaoyan.ui.activity.SplashActivity'
    desired_caps['noReset']=False

    driver = webdriver.Remote(f'http://{data["ip"]}:{data["port"]}/wd/hub', desired_caps)
    driver.implicitly_wait(10)
    sleep(3)
    logging.info('app start....')

    return  driver

if __name__ == '__main__':
    driver=desired_caps()